/*---------------------------------------
* Author:ZJ
* createDate:Tuesday, August 07, 2012
* Description:
*
------------------------------------------*/

#ifndef SERVSPACE_CONNECTIONMANAGER_HPP
#define SERVSPACE_CONNECTIONMANAGER_HPP

#include "StdAfx.h"
#include "connection.hpp"

namespace fly {

	namespace jld{

		namespace server {	

			class connection_manager: private boost::noncopyable
			{
			public:
				/// Add the specified connection to the manager and start it.
				void start(connection_ptr c);

				/// Stop the specified connection.
				void stop(connection_ptr c);

				void send(connection_ptr conn, queue<send_packet>& packets);

				//send msg to owner.
				void send_self(connection_ptr conn, const_buf_ptr const_send_buf);

				//send msg to all cnn.
				void send_all(const_buf_ptr send_buf);

				//Stop and add into attacker list
				void attack(connection_ptr conn_ptr);

				/// Stop all connections.
				void stop_all();

				//a total number of the current connection_manager 
				const size_t connection_size();
			private:
				/// The managed connections.
				set<connection_ptr> connections_;
			};
		}
	}
}


#endif // SERVSPACE_CONNECTIONMANAGER_HPP